<template>
  <div class="app-container">
    <el-row :gutter="5">
      <el-col style="padding-left: 20px" :span="20">
        <el-button type="primary" @click="">添加餐桌</el-button>
      </el-col>
    </el-row>
    <el-divider></el-divider>
    <el-row :gutter="5">
      <el-col style="padding: 20px" v-for="(desk,index) in deskList" :key="index" :span="4">
        <el-card :body-style="{ height:'120px' }">
          <div slot="header" class="clearfix">
            <span>{{ desk.deskNumber + '号餐桌' }}</span>
            <span style="float: right; padding: 3px 0;cursor:pointer" class="el-icon-circle-close"></span>
          </div>
          <div style="display:flex;">
            <div style="margin:auto;">
              <span>{{ desk.description }}</span>
            </div>
          </div>
          <div style="display:flex;">
            <div style="margin:20px auto;">
              <el-button type="success" size="small" round @click="openDialog(index)">后台点餐</el-button>
            </div>
          </div>
        </el-card>
      </el-col>
    </el-row>

    <el-dialog
      :visible.sync="open"
      :title="title"
      width="70%" append-to-body
    >
      <template slot="title">
        <el-row>
          <el-col :span="6">
            <el-button type="primary">
              {{currentDesk.deskNumber}}号餐桌
              <i class="el-icon-star-on el-icon--right"></i>
            </el-button>
          </el-col>
          <el-col style="text-align: center" :span="18">
            {{currentDesk.deskNumber}}号餐桌
          </el-col>
        </el-row>
      </template>
      <DeskInfo :desk="currentDesk"></DeskInfo>
    </el-dialog>

  </div>
</template>

<script>
import PictureManager from '@/components/ImageUpload/PictureManager'
import * as deskApi from '@/api/shop/desk'
import DeskInfo from '@/components/Desk'
export default {
  name: 'ShopDesk',
  components: {
    PictureManager,
    DeskInfo
  },
  data() {
    return {
      queryParam: {},
      deskList: [],
      open:false,
      title:'',
      currentDesk:{}
    }
  }
  ,
  computed: {},
  created() {
    this.getList()
   /* this.getDicts('banner_type').then(response => {
      this.bannerType = response.data
    })
    this.getDicts('redirect_type').then(response => {
      this.redirectType = response.data
    })*/
  }
  ,
  methods: {
    getList() {
      deskApi.deskList(this.queryParam).then(res => {
        this.deskList = res.rows
      })
    },
    openDialog(index){
      this.title="后台点餐";
      this.currentDesk=this.deskList[index];
      this.open=!this.open;
    }
  }
}

</script>
<style lang="scss" scoped>

</style>
